<?php

if($_POST['xmlhttp']){
	include_once('config.php');
	include_once(mnminclude.'group.php');

	$group = new Group();
	$group->id = $_POST['group'];
	$group->read();
	if ($group->privacy == 'open') {
		$state = 'approved';
	}
	if ($group->privacy == 'half') {
		$state = 'applied';
	}
	if ($group->privacy == 'closed') {
		echo 'deny';
		die();
	}
	
	$sendmsg = $group->add_user($_POST['user'],'normal',$state);

	switch ($sendmsg) {
		case true:
			if ($group->privacy == 'half') { 
				echo "applied";
			}
			else {
				echo "approved";
			}
			die();
			break;
		default:
			echo "fail";
			die();
			break;
	}
}
?>